package cn.net.sinodata.system.msghandler.parse;

import cn.net.sinodata.system.msghandler.parse.entitymapping.IEntityMapping;
import cn.net.sinodata.system.msghandler.parse.msgparse.IMessageParse;
import com.fasterxml.jackson.databind.node.ArrayNode;

import java.util.Map;

public class MsgParseHandler implements IMessageParse, IEntityMapping {

    private IMessageParse msgParse;
    private IEntityMapping entityMapping;

    public MsgParseHandler(IMessageParse msgParseHandler, IEntityMapping entityMapping) {
        this.msgParse = msgParseHandler;
        this.entityMapping = entityMapping;
    }

    @Override
    public <T> T parse(String msg) throws Exception {
        return msgParse.parse(msg);
    }

    @Override
    public <T> T entityMapping(ArrayNode dbRuleTpl, Object result, Class<T> clazz) throws Exception {
        return entityMapping.entityMapping(dbRuleTpl, result, clazz);
    }

    @Override
    public Map<Class, Object> multiEntityMapper(ArrayNode dbRuleTpl, Object result) throws Exception {
        return entityMapping.multiEntityMapper(dbRuleTpl, result);
    }
}
